package com.grace.cms.general.controller.general;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.grace.cms.common.domain.entity.CmsContact;
import com.grace.cms.general.service.IGeneralContactService;
import com.grace.common.core.controller.BaseController;
import com.grace.common.core.domain.AjaxResult;

@RestController
@RequestMapping("/{themeName}/general/contact")
public class GeneralContactController extends BaseController {

    @Autowired
    private IGeneralContactService cmsContactService;

    /**
     * 添加反馈
     * 支持匿名添加反馈
     *
     * @param cmsContact
     * @return
     */
    @PostMapping("/addContact")
    public AjaxResult addContact(@PathVariable(value = "themeName") String themeName, CmsContact cmsContact) {
        cmsContact.setVisible(0);
        cmsContact.setContactType(cmsContact.getContactType() == null ? 0 : cmsContact.getContactType());
        return success(cmsContactService.insertCmsContact(cmsContact));
    }

}
